import matplotlib.pyplot as plt
from matplotlib import rcParams

# 设置字体
rcParams['font.sans-serif'] = ['Microsoft YaHei', 'SimHei', 'Arial Unicode MS', 'sans-serif']
rcParams['axes.unicode_minus'] = False  # 解决负号显示问题

def draw_database_table_structure():
    fig, ax = plt.subplots(figsize=(10, 4))
    ax.axis('off')
    ax.axis('tight')

    data = [
        ["表名", "字段", "类型", "描述"],
        ["用户", "id", "UUID", "用户唯一标识"],
        ["用户", "name", "String", "用户名"],
        ["用户", "email", "String", "用户邮箱"],
        ["行程", "id", "UUID", "行程唯一标识"],
        ["行程", "title", "String", "行程标题"],
        ["行程", "userId", "UUID", "关联用户"],
        ["目的地", "id", "UUID", "目的地唯一标识"],
        ["目的地", "name", "String", "目的地名称"],
        ["目的地", "tripId", "UUID", "关联行程"],
        ["活动", "id", "UUID", "活动唯一标识"],
        ["活动", "title", "String", "活动标题"],
        ["活动", "destinationId", "UUID", "关联目的地"],
    ]

    table = ax.table(cellText=data, colLabels=None, cellLoc='center', loc='center')
    table.auto_set_font_size(False)
    table.set_fontsize(10)
    table.scale(1.2, 1.2)

    plt.title('表3.1_数据库表结构')
    plt.savefig('表3.1_数据库表结构.png')
    plt.close()

if __name__ == "__main__":
    draw_database_table_structure() 